package com.bigflexlib.x.mx.logging.Log
{
	import flash.utils.getQualifiedClassName;
	
	import mx.logging.ILogger;
	import mx.logging.Log;
	import mx.logging.LogEventLevel;
	import mx.logging.targets.TraceTarget;
	
	public class LogUtil
	{

		public static function setupStandardTraceTarget( filters:Array = null ):void
		{
            var logTarget:TraceTarget = new TraceTarget();
            if ( filters )
            	logTarget.filters=filters;

            // Log all log levels.
            logTarget.level = LogEventLevel.ALL;

            // Add date, time, category, and log level to the output.
            logTarget.includeDate = true;
            logTarget.includeTime = true;
            logTarget.includeCategory = true;
            logTarget.includeLevel = true;

            // Begin logging.
            Log.addTarget(logTarget);		
		}
		
		/**
		 * 
		 * Returns a logger following the simplest convention:
		 * For an object of class foo.bar.Clazz it will return a logger with category "foo.bar.Clazz"
		 * 
		 * @param instance
		 * @return 
		 * 
		 */		
		public static function getStandardLogger( instanceOrClass:Object ):ILogger
		{
			var category:String = getQualifiedClassName( instanceOrClass );
			category = category.split("::").join(".");
			return Log.getLogger( category );
		}
	}
}